<?php 

include '../utils/stock.php';
include '../utils/evaluator.php';
require('../utils/fpdf17/fpdf.php');
session_start() ;
?>
<html>
<head>
<script>
function open_win()
{
window.open("graph.php")
}
</script>
<style type="text/css">
body
{

font-family:"Calibri";}
}
</style>
</head>
<body>

<b>FINAL STEP </b>
<br>

<br>


<?php


$stock = new stock;
$stock->get_stock_quote($_SESSION['evaluator']->ticker);

//echo "<b>Anualised dividend: </b>";
//echo $_SESSION['evaluator']->anualised_dividend;
//echo "<br>";
//echo "<b>Present book value: </b>";
//echo $_SESSION['evaluator']->bookvalue2012;
//echo "<br>";
//echo "<b>Future book value: </b>";
//echo $_SESSION['evaluator']->getFBV();
//echo "<br>";
//echo "<b>Book value growth: </b>";
//echo $_SESSION['evaluator']->average_growth;
//echo "<br>";
//echo "<b>Federal note: </b>";
//echo $_SESSION['evaluator']->federal_note;
//echo "<br>";
//echo "<b>Years: </b>";
//echo "10";
//echo "<br>";
//echo "<b>Market price: </b>";
//echo "$stock->last";
//echo "<br>";
//echo "<br>";
//echo "<br>";

$i = $_SESSION['evaluator']->average_growth;
$l = $_SESSION['evaluator']->federal_note;
$n = 10;
$fbv = $_SESSION['evaluator']->getFBV();
$div = $_SESSION['evaluator']->anualised_dividend;
$iv = $div*((1-(1/(pow((1+$l),10))))/$l) +$fbv/(pow((1+$l),10));
$p = $stock->last;





echo "<i>Intrinsic value: </i>";

echo  "".addColor($_SESSION['evaluator']->getIntrinsicValue(), $p)."";
echo "<br>";
echo "<i>BV growth: </i>";
echo  $_SESSION['evaluator']->average_growth;

//$b = pow(($fbv / ($p - $div*((1-(1/(pow((1+$i),10))))/$i))),(1/$n))-1;
//echo "<br>";
//echo "<b>Expected anual return: </b>";
//echo  "".addColor($b, $l)."";
//echo "<br>";
//echo  "".addColor($_SESSION['evaluator']->getExpectedAnualReturn(), $l)."";


$_SESSION['intrinsicvalue'] = $iv;
$_SESSION['expectedreturn'] = $b;



function addColor($number, $reference){
	if($number >= $reference) 
	{
		$res = "<b><font color='green'>". $number . "</font></b>";
	}
	else 
	{
		$res = "<font color='red'>". $number . "</font>";
	}
	
	return $res;
}

?>
<br />
<br />
Add a modified growth perspective here:
<br />
<form action="step6.php" method="post">
Average 10y growth: <input type="text" name="avgro"  />
<br />
<input type="submit" value="Recalculate"/>
</form>
<br />


<button type="button" onclick="location.href='step4b.php'">Back</button>
<input type="button" value="Finish" onclick="open_win()" />



</body>
</html> 